<template>
  <q-page class="cc-admin">

    <div class="col bg-white shadow-2 q-pa-md q-ma-sm">
      <q-table flat color="primary" class="cross_table" separator="cell" :columns="columns" :data="list" row-key="id" :pagination.sync="pagination" :visible-columns="group" @request="query" :rows-per-page-options="[10, 20, 50, 100]" selection="multiple" :selected.sync="selected">

        <template v-slot:top="">
          <div class="row no-wrap full-width">
            <q-input clearable outlined dense placeholder="请输入关键字搜索" class="on-left" @input="query" debounce="500" v-model="key">
              <template #append>
                <q-btn flat round icon="search" color="primary" @click="query" :loading="loading">
                  <q-tooltip>搜索</q-tooltip>
                </q-btn>
              </template>
            </q-input>
            <q-space />
            <!-- <table-top-btns label="培训记录及效果评价表" modelName="smsCrewTrainRecord" :showAdd="true" :table="table"
              :selected="selected" :importing="importing" :exporting="exporting"
              :importExcelUrlFull="importExcelUrlFull" :columns="columns" @groupChange="groupChange" @add="add"
              @importExcel="importExcel" @exportExcel="exportExcel" @showConfirm="showConfirm" /> -->
            <div class="q-gutter-xs">
              <q-btn icon="add" no-wrap color="primary" label="新建" @click="add" />

            </div>
          </div>
        </template>
        <template #body-cell-opt="props">
          <q-td :props="props" :auto-width="true">
            <q-btn flat round dense color="primary" icon="edit" @click="edit(props.row)">
              <q-tooltip>编辑</q-tooltip></q-btn>
            <!-- <q-btn flat round dense color="primary" icon="mdi-content-copy" @click="copy(props.row)">
              <q-tooltip>复制</q-tooltip>
            </q-btn> -->
            <btn-del label="培训记录及效果评价表" @confirm="del(props.row)" />
          </q-td>
        </template>
      </q-table>
    </div>
    <q-dialog maximized flat persistent ref="dialog">
      <q-form @submit="submit" class="dialog_card column">
        <h5 class="view_title justify-between q-px-md">
          {{ editType }}
          <q-btn dense outline round icon="clear" size="sm" v-close-popup />
        </h5>
        <q-scroll-area class="col">
          <div class="row q-col-gutter-x-md dialog_form q-pa-md">
            <div class="display-item col-6">
              <div class="dynamic-form-item ">
                <div v-show="true" class="dynamic-form-item-label" style="width:100%;">
                  <q-icon name="star" color="red" v-show="true" />
                  培训项目
                </div>
                <q-input dense debounce="500" hide-bottom-space outlined v-model="form.trainProject" type="text" @blur="train_projectBlur102" @input="train_projectInput102(form
                  .trainProject, form)" lazy-rules autogrow />
              </div>
            </div>
            <div class="display-item col-6">
              <div class="dynamic-form-item ">
                <div v-show="true" class="dynamic-form-item-label" style="width:100%;">
                  <q-icon name="star" color="red" v-show="true" />
                  培训组织单位
                </div>
                <q-input dense debounce="500" hide-bottom-space outlined v-model="form.deptIdText" type="text" @input="train_projectInput102(form
                  .trainProject, form)" lazy-rules autogrow />
              </div>
            </div>
            <div class="display-item col-6" v-if="showForm[104]">
              <div class="dynamic-form-item ">
                <div v-show="true" class="dynamic-form-item-label" style="width:100%;">
                  <q-icon name="star" color="red" v-show="true" />
                  培训日期
                </div>
                <input-date-picker dense debounce="500" hide-bottom-space outlined v-model="form.date" type="date" :form="form" beginDate="" endDate="" :readonly="!editableForm[104]" />
              </div>
            </div>
            <div class="display-item col-6">
              <div class="dynamic-form-item ">
                <div v-show="true" class="dynamic-form-item-label" style="width:100%;">
                  <q-icon name="star" color="red" v-show="true" />
                  培训方式
                </div>
                <q-input v-if="!editableForm[101]" v-model="form.trainingMethod" class="readonly dense hide-bottom-space outlined " />
                <select-search dense debounce="500" hide-bottom-space outlined :options="trainingMethodList" v-model="form.trainingMethod" type="select" />
              </div>
            </div>
            <div class="display-item col-12">
              <div class="dynamic-form-item ">
                <div v-show="true" class="dynamic-form-item-label" style="width:100%;">
                  <q-icon name="star" color="red" v-show="true" />
                  受培训人员
                </div>
                <q-input dense debounce="500" hide-bottom-space outlined v-model="form.trainUser" type="text" lazy-rules autogrow />
              </div>
            </div>
            <div class="" style="width: 100% ;padding-left: 25px;padding-right: 12px;">
              <div v-show="true" class="dynamic-form-item-label" style="width:100%;">
                <q-icon name="star" color="red" v-show="true" />
                培训内容
              </div>
              <q-input v-model="form.trainContent" outlined type="textarea" />
            </div>

          </div>
        </q-scroll-area>
        <div class="row justify-center q-pa-md">
          <q-btn outline color="primary" icon="mdi-close-thick" label="关闭" v-close-popup />
          <q-btn class="q-mx-md" color="primary" icon="mdi-check-bold" label="提交" :loading="loading" type="submit" />
        </div>
      </q-form>
    </q-dialog>
    <confirm ref="confirmDialog" :msg="confirmMsg" @confirm="deleteBatch()" />
    <q-inner-loading :showing="loading">
      <q-spinner-gears size="50px" color="primary" />
    </q-inner-loading>
  </q-page>
</template>

<script>
import { IndexMixin } from 'boot/mixins';
import { getDictLabel } from 'boot/dictionary';
import confirm from 'components/confirm';

export default {
  name: 'A15SmsCrewTrainRecord',
  mixins: [IndexMixin],
  components: {
    confirm,
  },
  data() {
    return {
      trainingMethodList: ['授课', '自学', '其他'],

      form: {
        id: null,
        shipId: '',
        shipIdText: null,
        trainProject: null,
        deptId: '',
        deptIdText: null,
        date: null,
        trainingMethod: '',
        trainContent: '',
        other: '0',
        content: null,
        examTest: '0',
        questionInFace: '0',
        inquireAbout: '0',
        behaivorObservation: '0',
        evaResult: null,
        complete: null,
        trainUser: '',
      },
      emptyForm: {
        id: null,
        shipId: '',
        shipIdText: null,
        trainProject: null,
        deptId: '',
        deptIdText: null,
        date: null,
        trainingMethod: '',
        trainContent: '',
        other: '0',
        content: null,
        examTest: '0',
        questionInFace: '0',
        inquireAbout: '0',
        behaivorObservation: '0',
        evaResult: null,
        complete: null,
        trainUser: '',

      },
      eva_resultOptions: [{
        label: '优 ：掌握了培训内容',
        value: '1'
      }, {
        label: '良 ：熟悉了培训内容',
        value: '2'
      }, {
        label: '中 ：基本清楚培训目标',
        value: '3',
        children: []
      }, {
        label: ' 差 ：未达到预期培训目标',
        value: '4',
        children: []
      }],
      eva_resultOptionData: [],
      completeOptions: [{
        label: '培训符合要求',
        value: '1'
      }, {
        label: '培训未通过，需再培训',
        value: '2'
      }],
      completeOptionData: [],
      sysShip: [],
      sysDepart: [],
      showForm: {
        101: true,
        102: true,
        103: true,
        104: true,
        107: true,
        110: true,
        111: true,
        118: true,
        119: true,
        120: true,
        121: true,
        122: true,
        123: true,
        124: true,
        125: true,
        126: true
      },
      editableForm: {
        101: true,
        102: true,
        103: true,
        104: true,
        107: true,
        110: true,
        111: true,
        118: true,
        119: true,
        120: true,
        121: true,
        122: true,
        123: true,
        124: true,
        125: true,
        126: true
      },
      columns: [
        {
          name: 'index',
          align: 'center',
          label: '序号',
          field: 'index',
        },
        {
          name: 'trainProject', align: 'center', label: '培训项目', field: 'trainProject',
        },
        {
          name: 'date', align: 'center', label: '培训日期', field: 'date',
        },
        {
          name: 'opt', align: 'center', label: '操作', field: 'id',
        },
      ],
      showQuery: true,
      headers: [{ name: 'Authorization', value: localStorage.Authorization }],
      uploadUrl: `${process.env.SERVER_URL}${process.env.BASE_URL}/sys/common/upload`,
      imgUrl: `${process.env.SERVER_URL}${process.env.BASE_URL}/sys/common/static`,
      url: {
        list: '/wea/trainRecord/list',
        add: '/wea/trainRecord/add',
        edit: '/wea/trainRecord/edit',
        copy: '/wea/trainRecord/copy',
        delete: '/wea/trainRecord/delete',
        deleteBatch: '/wea/trainRecord/deleteBatch',
        exportXlsUrl: '/wea/trainRecord/exportXls',
        importExcelUrl: '/wea/trainRecord/importExcel',
      },
    };
  },
  methods: {

    completeInput111(v, row, editAfter) {
    },
    eva_resultInput110(v, row, editAfter) {
    },
    eva_resultBlur110(evt, editAfter) {
    },
    completeBlur111(evt, editAfter) {
    },
    behaivor_observationInput124(v, row, editAfter) {
    },
    inquire_aboutInput123(v, row, editAfter) {
    },
    question_in_faceInput122(v, row, editAfter) {
    },
    behaivor_observationBlur124(evt, editAfter) {
    },
    examBlur125(evt, editAfter) {
    },
    question_in_faceBlur122(evt, editAfter) {
    },
    inquire_aboutBlur123(evt, editAfter) {
    },
    examInput125(v, row, editAfter) {
    },
    field126Input126(v, row, editAfter) {
    },
    study_selfInput120(v, row, editAfter) {
    },
    other11Input119(v, row, editAfter) {
    },
    train_projectBlur102(evt, editAfter) {
    },
    dept_idBlur103(evt, editAfter) {
    },
    dateBlur104(evt, editAfter) {
    },
    study_selfBlur120(evt, editAfter) {
    },
    other11Blur119(evt, editAfter) {
    },
    class11Blur118(evt, editAfter) {
    },
    field121Blur121(evt, editAfter) {
    },
    class11Input118(v, row, editAfter) {
    },
    train_projectInput102(v, row, editAfter) {
    },
    ship_idBlur101(evt, editAfter) {
    },
    ship_idInput101(v, row, editAfter) {
      if (v instanceof Array) {
        const nameArray = [];
        if (this.form) {
          this.form.shipIdText = '';
          v.forEach((id) => {
            const opt = this.sysShip.find((o) => o.value === id);
            if (opt) {
              nameArray.push(opt.label);
            }
            this.form.shipIdText = nameArray.join(',');
          });
        }
      } else {
        const opt = this.sysShip.find((o) => o.value === v);
        if (opt) {
          this.form.shipIdText = opt.label;
        }
        if (!v) {
          this.form.shipIdText = '';
        }
      }
    },
    getDictLabel,
    initDict() {
      this.$axios.get('/sys/dictItem/selectItemsByDefId?defId=trainWay').then((r) => {
        this.trainingmode = r;
      });
      this.$axios.get('/sys/dictItem/selectItemsByDefId?defId=trainType').then((r) => {
        this.crewtrainingTrainingType = r;
      });
      this.$axios.get('/sys/dictItem/selectItemsByDefId?defId=shipdept').then((r) => {
        this.sysDepart = r;
      });
      this.$axios.get('/sys/dictItem/selectItemsByDefId?defId=sysShip').then((r) => {
        this.sysShip = r;
      });
    },
  },
  mounted() {
    this.initDict();
  },
};
</script>

<style lang="stylus">

</style>
